<%@page import="javax.print.attribute.standard.Finishings"%><%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="java.util.*,Test.*,java.lang.reflect.*"%>
<% 		
	request.setCharacterEncoding("UTF-8");
	response.setCharacterEncoding("UTF-8");	
	 
    String methodName = request.getParameter("method");
    
    try{
	    Class[] argsClass = new Class[2]; 
	    argsClass[0] = HttpServletRequest.class;
	    argsClass[1] = HttpServletResponse.class;
	    
	    Class cls = this.getClass();   
	    Method method = cls.getMethod(methodName, argsClass);   
	    
	    Object[] args = new Object[2];
	    args[0] = request;
	    args[1] = response;   
	    
	    BeforeInvoke(methodName);
	    method.invoke(this, args);     
    }catch( Exception e){
        HashMap result = new HashMap();
        result.put("error", -1);
        result.put("message", e.getMessage());
        result.put("stackTrace", e.getStackTrace());
        String json = Test.JSON.Encode(result);
        response.reset();
        response.getWriter().write(json);
    }        
    finally
    {
        AfterInvoke(methodName);
    }
%>
<%!
//权限管理
protected void BeforeInvoke(String methodName)
{
    //Hashtable user = GetUser();
    //if (user.role == "admin" && methodName == "remove") throw .      
}
//日志管理
protected void AfterInvoke(String methodName)
{
	
}
//////////////////////////////////////
public void SearchPositions(HttpServletRequest request, HttpServletResponse response) throws Exception
{ 	//查询职位	
    //查询条件
    String key = request.getParameter("key");
    //分页
    int pageIndex = Integer.parseInt(request.getParameter("pageIndex"));
    int pageSize = Integer.parseInt(request.getParameter("pageSize"));        
    //字段排序
    String sortField = request.getParameter("sortField");
    String sortOrder = request.getParameter("sortOrder");
	System.out.println(key);
    HashMap result = new Test.PositionDB().SearchPositions(key, pageIndex, pageSize, sortField, sortOrder);
    String json = Test.JSON.Encode(result);
    response.getWriter().write(json);
}

public void GetPosition(HttpServletRequest request, HttpServletResponse response) throws Exception
{
    String position_id = request.getParameter("position_id");
    HashMap position = new Test.PositionDB().GetPosition(Integer.parseInt(position_id));
    String json = Test.JSON.Encode(position);
    response.getWriter().write(json);
}
public void SearchJobCategory(HttpServletRequest request, HttpServletResponse response) throws Exception
{
    String jobCategory = request.getParameter("jobCategory");
    if(jobCategory.equals("yanfachu")){
    	jobCategory = "研发处";
    }else if(jobCategory.equals("chanpinchu")){
    	jobCategory = "产品处";
    }else if(jobCategory.equals("guojiyewuchu")){
    	jobCategory = "国际业务处";
    }else if(jobCategory.equals("zhizhaochu")){
    	jobCategory = "制造处";
    }else if(jobCategory.equals("caiwuchu")){
    	jobCategory = "财务处";
    }else{
    	jobCategory = "人事行政处";
    }
    System.out.println("查找关键词："+jobCategory);
    ArrayList data = new Test.PositionDB().SearchJobCategory(jobCategory);
    String json = Test.JSON.Encode(data);
    System.out.println("查找结果："+json);
    response.getWriter().write(json);
}

%> 